<?php

namespace app\common\model\newhouse;

use think\Model;


class NewhouseVideo extends Model
{

    

    

    // 表名
    protected $name = 'newhouse_video';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'fovi_text',
        'lx_text',
        'good_text',
        'flag_text'
    ];
    

    
    public function getFoviList()
    {
        return ['0' => __('Fovi 0'), '1' => __('Fovi 1'), '2' => __('Fovi 2'), '3' => __('Fovi 3'), '4' => __('Fovi 4'), '5' => __('Fovi 5'), '6' => __('Fovi 6'), '7' => __('Fovi 7'), '8' => __('Fovi 8'), '9' => __('Fovi 9')];
    }

    public function getLxList()
    {
        return ['0' => __('Lx 0'), '1' => __('Lx 1'), '2' => __('Lx 2'), '3' => __('Lx 3')];
    }

    public function getGoodList()
    {
        return ['0' => __('Good 0'), '1' => __('Good 1')];
    }

    public function getFlagList()
    {
        return ['0' => __('Flag 0'), '1' => __('Flag 1')];
    }


    public function getFoviTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['fovi']) ? $data['fovi'] : '');
        $list = $this->getFoviList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getLxTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['lx']) ? $data['lx'] : '');
        $list = $this->getLxList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getGoodTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['good']) ? $data['good'] : '');
        $list = $this->getGoodList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getFlagTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['flag']) ? $data['flag'] : '');
        $list = $this->getFlagList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function category()
    {
        return $this->belongsTo('app\common\model\Category', 'category_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
